import request from 'umi-request'
import {message} from 'antd'
export async function get(url:string,params:object){
    return request('/campus/campusweb/' + url,{
        params
    }).then(function(response){
        let result = response
        if(result.code !== 200){
            throw new Error(result.message)
        }
        return response.data
    }).catch(function(error){
        message.error(`接口请求失败：${error}`)
        return error
    })
}
export async function post(url:string,params:object){
    return request('/campus/campusweb/' + url,{
        method:'post',
        data:params
    }).then(function(response){
        let result = response
        try {
            if(result.code == 200){
                return result.data
            } else {
                throw(result)
            }
		} catch (err) {
			return response
		}
    },err=>{
        return err.message
    }).catch(function(error){
        message.error(`接口请求失败：${error}`)
        return error
    })
}